<template>
  <div id="recruitTable">
    <el-dialog title="退回原因" :visible.sync="backFormVisible" :close-on-click-modal="false" width="700px" :close-on-press-escape="false">
      <el-form :model="backForm" ref="backForm" :inline="true" inline-message>
        <el-form-item prop="remark">
          <el-input v-model="backForm.remark" style="width:600px"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click.native="setState(5)" :loading="btnLoading">提交</el-button>
        <el-button @click.native="backFormVisible = false">取消</el-button>
      </div>
    </el-dialog>
    <template>
      <h1 style="text-align:center">{{theYear}}2023年度招聘岗位</h1>
      <el-table :data="postList" highlight-current-row v-loading="listLoading" style="width: 100%;margin-bottom: 20px;" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column type="index" label="序号" width="60" align="center">
        </el-table-column>
        <el-table-column prop="state" label="状态" width="80" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.state===0">未完成</span>
            <span v-else style="color:green;font-weight:bolder">已完成</span>
          </template>
        </el-table-column>
        <el-table-column prop="theType" label="岗位类型" width="150" align="center">
        </el-table-column>
        <el-table-column prop="unitName" label="单位名称" min-width="150" header-align="center">
        </el-table-column>
        <el-table-column prop="department" label="具体工作部门" width="250" header-align="center">
        </el-table-column>
        <el-table-column prop="post" label="岗位" width="150" header-align="center">
        </el-table-column>
        <el-table-column prop="major" label="专业" width="250" header-align="center">
        </el-table-column>
        <el-table-column prop="education" label="学历要求" width="120" align="center">
        </el-table-column>
      </el-table>
    </template>
    <div v-if="canEdit">
      <el-upload
        style="width:800px;margin-bottom:10px;"
        ref="upload"
        :action="this.$http.defaults.baseURL+this.$http.defaults.recruitAPI +'api/recruitGenFileInfo/upload'"
        :on-success="handleUploadSucc1"
        :on-error="uploadError"
        :before-upload="beforeUpload"
        accept="application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-works,.wps"
        :show-file-list="false"
      >
        <el-button type="primary" :loading="saveloading">{{step==='bus_announcement'?'上传招聘公告文件':'上传拟聘人选公示文件'}}</el-button>
        <!-- <div slot="tip" class="el-upload__tip">注：支持上传word/pdf/wps文件</div>
        <div style="clear:both" /> -->
      </el-upload>
    </div>
    <div v-if="!fileListLoading">
      <template v-if="files&&files.length>0">
        <div v-for="(item,index) in files" :key="index" style="height:40px;line-height:40px">
          <a href="javascript:void(0)" @click="download(item.id)"><i class="el-icon-paperclip" /> {{item.fileName}}.{{item.fileType}}</a>
          <el-button v-if="canEdit" style="margin-left:10px" size="mini" type="danger" @click="beforeRemove(item,step,'files')">删除</el-button>
          <!-- <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template> -->
        </div>
      </template>
    </div>
    <div v-else>加载中...</div>
    <template v-if="batchState">
      <el-button icon="el-icon-s-promotion" type="success" style="margin-bottom:20px" @click="setState(1)" v-if="canEdit&&(state===0||state===5)" :loading='btnLoading'>提交</el-button>
      <el-button icon="el-icon-s-release" type="danger" style="margin-bottom:20px" v-if="canAudit&&state===1" @click="showBack()">退回</el-button>
    </template>
    <template>
      <h1 style="text-align:center">已提交批次</h1>
      <el-table :data="batchList" highlight-current-row v-loading="listLoading" style="width: 100%;margin-bottom: 20px;">
        <el-table-column prop="state" label="状态" width="150" align="center">
          <template slot-scope="scope">
            <el-tooltip v-if="scope.row.state===0" class="item" effect="dark" content="退回时间：2023年12月12日 退回原因：资料未盖章" placement="top" :open-delay="500">
              <el-tag effect="dark" type="danger" style="cursor: pointer;">已退回</el-tag>
            </el-tooltip>
            <el-tooltip v-else-if="scope.row.state===1" class="item" effect="dark" content="提交时间：2023年12月13日" placement="top" :open-delay="500">
              <el-tag effect="dark" style="cursor: pointer;">待初审</el-tag>
            </el-tooltip>
            <el-tooltip v-else-if="scope.row.state===2" class="item" effect="dark" content="提交时间：2023年12月13日" placement="top" :open-delay="500">
              <el-tag effect="dark" type="success" style="cursor: pointer;">已发布</el-tag>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column prop="num" label="岗位数量" width="150" align="center">
          <template slot-scope="scope">
            <el-popover placement="right" trigger="hover" :open-delay="500">
              <div class="recruitTable">
                <el-table :data="batchPostList" border>
                  <el-table-column prop="theType" label="岗位类型" width="150" align="center">
                  </el-table-column>
                  <el-table-column prop="unitName" label="单位名称" width="250" header-align="center">
                  </el-table-column>
                  <el-table-column prop="department" label="具体工作部门" width="250" header-align="center">
                  </el-table-column>
                  <el-table-column prop="post" label="岗位" width="150" header-align="center">
                  </el-table-column>
                  <el-table-column prop="major" label="专业" width="250" header-align="center">
                  </el-table-column>
                  <el-table-column prop="education" label="学历要求" width="150" align="center">
                  </el-table-column>
                </el-table>
              </div>
              <el-button slot="reference" type="text" icon="el-icon-search">{{scope.row.num}}</el-button>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column prop="files" label="附件" min-width="150">
          <template slot-scope="scope">
            <div v-if="!fileListLoading">
              <template v-if="files&&files.length>0">
                <div v-for="(item,index) in files" :key="index" style="height:40px;line-height:40px">
                  <a href="javascript:void(0)" @click="download(item.id)"><i class="el-icon-paperclip" /> {{item.fileName}}.{{item.fileType}}</a>
                </div>
              </template>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <!-- <div v-else style="padding:20px; font-size:14px;color:#999;text-align:center">暂无数据</div> -->
  </div>
</template>
<script>
export default {
  props: {
    step: '',
    batchState: null,
    timestamp: '',
    canEdit: null,
    unitBatchId: null,
    type: null,
    theYear: null,
    startYear: null,
    state: null,
    canAudit: null
  },
  watch: {
    step (val) {
      console.log(val)
    },
    timestamp (val) {
      if (this.step === 'bus_candidate_registration' || this.step === 'bus_settlement_registration') {
        this.getList()
      }
      this.getFileList()
    },
    canEdit (val) {
      console.log(val)
    },
    type (val) {
      console.log(val)
    },
    unitBatchId (val) {
      console.log(val)
    },
    theYear (val) {
      console.log(val)
    },
    startYear (val) {
      console.log(val)
    },
    state (val) {
      console.log(val)
    },
    batchState (val) {
      console.log(val)
    },
    canAudit (val) {
      console.log(val)
    }
  },
  data () {
    return {
      batchList: [
        {unitName: '111', beijing: '京内', num: 2, state: 0},
        {unitName: '111', beijing: '京内', num: 2, state: 1},
        {unitName: '111', beijing: '京内', num: 3, state: 2}
      ],
      batchPostList: [
        {unitName: '111(京内)', theType: '应届毕业生招聘', beijing: '京内', department: '财务处', post: '出纳', major: '会计学', education: '本科生', state: 1},
        {unitName: '111(京内)', theType: '在职招聘', beijing: '京外', department: '办公室', post: '文员', major: '汉语言', education: '硕士研究生', state: 0}
      ],
      postList: [
        {unitName: '111(京内)', theType: '应届毕业生招聘', beijing: '京内', education: '大专', department: '财务处', post: '出纳', major: '会计学', state: 0},
        {unitName: '111(京内)', theType: '应届毕业生招聘', beijing: '京内', education: '本科生', department: '办公室', post: '文员', major: '汉语言', state: 1},
        {unitName: '111(京内)', theType: '应届毕业生招聘', beijing: '京内', education: '本科生', department: '财务处', post: '出纳', major: '会计学', state: 2},
        {unitName: '111(京内)', theType: '在职招聘', beijing: '京外', education: '硕士研究生', department: '办公室', post: '文员', major: '汉语言', state: 0},
        {unitName: '111(京内)', theType: '在职招聘', beijing: '京外', education: '其他', department: '信息中心', post: '科员', major: '计算机', state: 0}
      ],
      list1: [
        {unitName: '111', beijing: '京内', education: '大专', state: 0},
        {unitName: '111', beijing: '京内', education: '本科生', state: 1},
        {unitName: '111', beijing: '京内', education: '本科生', state: 2},
        {unitName: '111', beijing: '京外', education: '硕士研究生', state: 0},
        {unitName: '111', beijing: '京外', education: '其他', state: 0}
      ],
      list2: [
        {unitName: '111', education: '硕士研究生', state: 2},
        {unitName: '111', education: '博士研究生', state: 1},
        {unitName: '111', education: '硕士研究生', state: 0}
      ],
      list3: [
        {unitName: '111', state: 1},
        {unitName: '111', state: 2},
        {unitName: '111', state: 0}
      ],
      dialogTitle: '',
      // 专业类别未补全、民族未补全
      options: [
        {
          value: '文学',
          label: '文学',
          children: [
            {
              value: '中国语言文学',
              label: '中国语言文学'
            },
            {
              value: '外国语言文学',
              label: '外国语言文学'
            }
          ]
        },
        {
          value: '历史学',
          label: '历史学',
          children: [
            {
              value: '历史学',
              label: '历史学'
            }
          ]
        },
        {
          value: '哲学',
          label: '哲学',
          children: [
            {
              value: '哲学类',
              label: '哲学类'
            }
          ]
        }
      ],
      typeList: [{label: '应届毕业生招聘', value: 2}, {label: '在职人员招聘', value: 1}],
      sexList: [{label: '男', value: 1}, {label: '女', value: 0}],
      nationList: [
        '汉族',
        '蒙古族',
        '回族',
        '藏族',
        '维吾尔族',
        '苗族',
        '彝族',
        '壮族',
        '布依族',
        '朝鲜族',
        '满族',
        '侗族',
        '瑶族',
        '白族',
        '土家族',
        '哈尼族',
        '哈萨克族',
        '傣族',
        '黎族',
        '傈僳族',
        '佤族',
        '畲族',
        '高山族',
        '拉祜族',
        '水族',
        '东乡族',
        '纳西族',
        '景颇族',
        '柯尔克孜族',
        '土族',
        '达斡尔族',
        '仫佬族',
        '羌族',
        '布朗族',
        '撒拉族',
        '毛南族',
        '仡佬族',
        '锡伯族',
        '阿昌族',
        '普米族',
        '塔吉克族',
        '怒族',
        '乌孜别克族',
        '俄罗斯族',
        '鄂温克族',
        '德昂族',
        '保安族',
        '裕固族',
        '京族',
        '塔塔尔族',
        '独龙族',
        '鄂伦春族',
        '赫哲族',
        '门巴族',
        '珞巴族',
        '基诺族'
      ],
      maritalStatusList: ['未婚', '已婚', '离婚', '丧偶'],
      degreeList: ['博士', '硕士', '学士', '其他'],
      educationList: ['大专', '本科生', '硕士研究生', '博士研究生', '其他'],
      recruitmentMethodList: [{label: '考试', value: 1}, {label: '引进', value: 2}],
      editLoading: false,
      backForm: {remark: ''},
      backFormVisible: false,
      fileListLoading: false,
      btnLoading: false,
      saveloading: false,
      files: [],
      listLoading: false,
      addFormVisible: false,
      addFormVisible_2: false,
      addFormVisible2: false,
      list: [],
      list_2: [],
      editFormRules: {
        unitName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        theType: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        department: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        post: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        realName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        idCardNo: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        sex: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        nation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        maritalStatus: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        school: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        schoolLocation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        place: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        major: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        majorClass1: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        education: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        degree: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        recruitmentMethod: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputer: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputerPhone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputDate: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        originalUnit: [
          { required: true, message: '必填', trigger: 'blur' }
        ]
      },
      editFormbRules: {
        unitName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        theType: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        department: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        post: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        realName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        idCardNo: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        sex: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        nation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        maritalStatus: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        school: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        schoolLocation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        place: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        major: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        majorClass1: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        education: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        degree: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        recruitmentMethod: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputer: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputerPhone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputDate: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        originalUnit: [
          { required: true, message: '必填', trigger: 'blur' }
        ]
      },
      editForm: {
        id: null,
        unitName: '',
        theType: '',
        department: '',
        post: '',
        realName: '',
        idCardNo: '',
        sex: '',
        nation: '',
        maritalStatus: '',
        phone: '',
        school: '',
        schoolLocation: '',
        place: '',
        major: '',
        majorClass1: '',
        majorClass2: '',
        education: '',
        degree: '', // 表单缺
        recruitmentMethod: '', // 表单缺
        inputer: '',
        inputerPhone: '',
        inputDate: '',
        originalUnit: ''
      },
      editFormb: {
        id: null,
        unitName: '',
        theType: '',
        department: '',
        post: '',
        realName: '',
        idCardNo: '',
        sex: '',
        nation: '',
        maritalStatus: '',
        phone: '',
        school: '',
        schoolLocation: '',
        place: '',
        major: '',
        majorClass1: '',
        majorClass2: '',
        education: '',
        degree: '', // 表单缺
        recruitmentMethod: '', // 表单缺
        inputer: '',
        inputerPhone: '',
        inputDate: '',
        originalUnit: ''
      },
      // 以下初始变量未更新
      editFormRules2: {
        unitName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        realName: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        sex: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        nation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        maritalStatus: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        idCardNo: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        education: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        place: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        school: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        graduationCertificateNumber: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        schoolLocation: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        degreeCertificateNumber: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        relocationAddress: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        relocationOrgan: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        movingInAddress: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        movingInOrgan: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputer: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputerPhone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputerCellPhone: [
          { required: true, message: '必填', trigger: 'blur' }
        ],
        inputDate: [
          { required: true, message: '必填', trigger: 'blur' }
        ]
      },
      editForm2: {
        id: null,
        unitName: '',
        realName: '',
        sex: '',
        nation: '',
        maritalStatus: '',
        idCardNo: '',
        education: '',
        place: '',
        school: '',
        graduationCertificateNumber: '',
        schoolLocation: '',
        degreeCertificateNumber: '',
        relocationAddress: '',
        relocationOrgan: '',
        movingInAddress: '',
        movingInOrgan: '',
        phone: '',
        inputer: '',
        inputerPhone: '',
        inputerCellPhone: '',
        inputDate: ''
      }
    }
  },
  methods: {
    handleAdd (theType) {
      this.dialogTitle = '新增'
      if (theType === 1) {
        this.editForm.id = null
        this.editForm.unitName = ''
        this.editForm.theType = theType
        this.editForm.department = ''
        this.editForm.post = ''
        this.editForm.realName = ''
        this.editForm.idCardNo = ''
        this.editForm.sex = ''
        this.editForm.nation = ''
        this.editForm.maritalStatus = ''
        this.editForm.phone = ''
        this.editForm.school = ''
        this.editForm.schoolLocation = ''
        this.editForm.place = ''
        this.editForm.major = ''
        this.editForm.majorClass1 = ''
        this.editForm.majorClass2 = ''
        this.editForm.education = ''
        this.editForm.degree = ''
        this.editForm.recruitmentMethod = ''
        this.editForm.inputer = ''
        this.editForm.inputerPhone = ''
        this.editForm.inputDate = ''
        this.editForm.originalUnit = ''
        this.addFormVisible = true
      } else {
        this.editFormb.id = null
        this.editFormb.unitName = ''
        this.editFormb.theType = theType
        this.editFormb.department = ''
        this.editFormb.post = ''
        this.editFormb.realName = ''
        this.editFormb.idCardNo = ''
        this.editFormb.sex = ''
        this.editFormb.nation = ''
        this.editFormb.maritalStatus = ''
        this.editFormb.phone = ''
        this.editFormb.school = ''
        this.editFormb.schoolLocation = ''
        this.editFormb.place = ''
        this.editFormb.major = ''
        this.editFormb.majorClass1 = ''
        this.editFormb.majorClass2 = ''
        this.editFormb.education = ''
        this.editFormb.degree = ''
        this.editFormb.recruitmentMethod = ''
        this.editFormb.inputer = ''
        this.editFormb.inputerPhone = ''
        this.editFormb.inputDate = ''
        this.editFormb.originalUnit = ''
        this.addFormVisible_2 = true
      }
    },
    handleDetail (obj, theType) {
      this.dialogTitle = this.canEdit ? '修改' : '详情'
      if (theType === 1) {
        this.editForm.id = obj.id
        this.editForm.unitName = obj.unitName
        this.editForm.theType = obj.theType
        this.editForm.department = obj.department
        this.editForm.post = obj.post
        this.editForm.realName = obj.realName
        this.editForm.idCardNo = obj.idCardNo
        this.editForm.sex = obj.sex
        this.editForm.nation = obj.nation
        this.editForm.maritalStatus = obj.maritalStatus
        this.editForm.phone = obj.phone
        this.editForm.school = obj.school
        this.editForm.schoolLocation = obj.schoolLocation
        this.editForm.place = obj.place
        this.editForm.major = obj.major
        this.editForm.majorClass1 = obj.majorClass1
        this.editForm.majorClass2 = obj.majorClass2
        this.editForm.education = obj.education
        this.editForm.degree = obj.degree
        this.editForm.recruitmentMethod = obj.recruitmentMethod
        this.editForm.inputer = obj.inputer
        this.editForm.inputerPhone = obj.inputerPhone
        this.editForm.inputDate = obj.inputDate
        this.editForm.originalUnit = obj.originalUnit
        this.addFormVisible = true
      } else {
        this.editFormb.id = obj.id
        this.editFormb.unitName = obj.unitName
        this.editFormb.theType = obj.theType
        this.editFormb.department = obj.department
        this.editFormb.post = obj.post
        this.editFormb.realName = obj.realName
        this.editFormb.idCardNo = obj.idCardNo
        this.editFormb.sex = obj.sex
        this.editFormb.nation = obj.nation
        this.editFormb.maritalStatus = obj.maritalStatus
        this.editFormb.phone = obj.phone
        this.editFormb.school = obj.school
        this.editFormb.schoolLocation = obj.schoolLocation
        this.editFormb.place = obj.place
        this.editFormb.major = obj.major
        this.editFormb.majorClass1 = obj.majorClass1
        this.editFormb.majorClass2 = obj.majorClass2
        this.editFormb.education = obj.education
        this.editFormb.degree = obj.degree
        this.editFormb.recruitmentMethod = obj.recruitmentMethod
        this.editFormb.inputer = obj.inputer
        this.editFormb.inputerPhone = obj.inputerPhone
        this.editFormb.inputDate = obj.inputDate
        this.editFormb.originalUnit = obj.originalUnit
        this.addFormVisible_2 = true
      }
    },
    handleAdd2 () {
      this.dialogTitle = '新增'
      this.editForm2.id = null
      this.editForm2.unitName = ''
      this.editForm2.realName = ''
      this.editForm2.sex = ''
      this.editForm2.nation = ''
      this.editForm2.maritalStatus = ''
      this.editForm2.idCardNo = ''
      this.editForm2.education = ''
      this.editForm2.place = ''
      this.editForm2.school = ''
      this.editForm2.graduationCertificateNumber = ''
      this.editForm2.schoolLocation = ''
      this.editForm2.degreeCertificateNumber = ''
      this.editForm2.relocationAddress = ''
      this.editForm2.relocationOrgan = ''
      this.editForm2.movingInAddress = ''
      this.editForm2.movingInOrgan = ''
      this.editForm2.phone = ''
      this.editForm2.inputer = ''
      this.editForm2.inputerPhone = ''
      this.editForm2.inputerCellPhone = ''
      this.editForm2.inputDate = ''
      this.addFormVisible2 = true
    },
    handleDetail2 (obj) {
      this.dialogTitle = this.canEdit ? '修改' : '详情'
      this.editForm2.id = obj.id
      this.editForm2.unitName = obj.unitName
      this.editForm2.realName = obj.realName
      this.editForm2.sex = obj.sex
      this.editForm2.nation = obj.nation
      this.editForm2.maritalStatus = obj.maritalStatus
      this.editForm2.idCardNo = obj.idCardNo
      this.editForm2.education = obj.education
      this.editForm2.place = obj.place
      this.editForm2.school = obj.school
      this.editForm2.graduationCertificateNumber = obj.graduationCertificateNumber
      this.editForm2.schoolLocation = obj.schoolLocation
      this.editForm2.degreeCertificateNumber = obj.degreeCertificateNumber
      this.editForm2.relocationAddress = obj.relocationAddress
      this.editForm2.relocationOrgan = obj.relocationOrgan
      this.editForm2.movingInAddress = obj.movingInAddress
      this.editForm2.movingInOrgan = obj.movingInOrgan
      this.editForm2.phone = obj.phone
      this.editForm2.inputer = obj.inputer
      this.editForm2.inputerPhone = obj.inputerPhone
      this.editForm2.inputerCellPhone = obj.inputerCellPhone
      this.editForm2.inputDate = obj.inputDate
      this.addFormVisible2 = true
    },
    editFormSubmit2 () {
      this.$refs.editForm2.validate((valid) => {
        if (valid) {
          this.editLoading = true
          let para = {
            id: this.editForm2.id,
            unitName: this.editForm2.unitName,
            realName: this.editForm2.realName,
            sex: this.editForm2.sex,
            nation: this.editForm2.nation,
            maritalStatus: this.editForm2.maritalStatus,
            idCardNo: this.editForm2.idCardNo,
            education: this.editForm2.education,
            place: this.editForm2.place,
            school: this.editForm2.school,
            graduationCertificateNumber: this.editForm2.graduationCertificateNumber,
            schoolLocation: this.editForm2.schoolLocation,
            degreeCertificateNumber: this.editForm2.degreeCertificateNumber,
            relocationAddress: this.editForm2.relocationAddress,
            relocationOrgan: this.editForm2.relocationOrgan,
            movingInAddress: this.editForm2.movingInAddress,
            movingInOrgan: this.editForm2.movingInOrgan,
            phone: this.editForm2.phone,
            inputer: this.editForm2.inputer,
            inputerPhone: this.editForm2.inputerPhone,
            inputerCellPhone: this.editForm2.inputerCellPhone,
            inputDate: this.editForm2.inputDate,
            unitBatchId: this.unitBatchId
          }
          this.$http.post(this.$http.defaults.recruitAPI + `api/recruitBusSettlementRegistration/save`, para).then(response => {
            console.log(response.data.success)
            if (response.data.success === true) {
              this.$message({
                message: '提交成功',
                type: 'success'
              })
              this.addFormVisible2 = false
              this.editLoading = false
              this.getList()
            } else {
              console.log('提交失败:' + response.data.message)
              this.$message({
                message: '提交失败:' + response.data.message,
                type: 'error'
              })
              this.editLoading = false
            }
          }).catch(error => {
            console.log(error)
            this.$message({
              message: '提交失败:' + error,
              type: 'error'
            })
            this.editLoading = false
          })
        }
      })
    },
    export1 (theType) {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.recruitAPI + 'api/recruitBusCandidateRegistration/export?unitBatchId=' + this.unitBatchId + '&type=' + theType)
    },
    export2 () {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.recruitAPI + 'api/recruitBusSettlementRegistration/export?unitBatchId=' + this.unitBatchId)
    },
    del (id) {
      // 未作table2处理
      let tableName = 'recruitBusCandidateRegistration'
      if (this.step === 'bus_settlement_registration') {
        tableName = 'recruitBusSettlementRegistration'
      }
      this.$confirm('确认删除该记录吗?', '提示', {
        type: 'warning'
      }).then(() => {
        let para = {ids: [id]}
        this.listLoading = true
        this.$http.post(this.$http.defaults.recruitAPI + 'api/' + tableName + '/remove', para).then(response => {
          if (response.data.success === true) {
            this.addLoading = false
            this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            console.log('删除失败:' + response.data.message)
            this.$message({
              message: '删除失败:' + response.data.message,
              type: 'error'
            })
          }
          this.getList()
        })
          .catch(error => {
            console.log(error)
            this.$message({
              message: '删除失败:' + error,
              type: 'error'
            })
          })
      })
    },
    getList () {
      // 未作table2处理
      let tableName = 'recruitBusSettlementRegistration'
      this.listLoading = true
      let para = {
        pageNum: 1,
        pageSize: 1000,
        unitBatchId: this.unitBatchId
      }
      if (this.step === 'bus_candidate_registration') {
        tableName = 'recruitBusCandidateRegistration'
        para.theType = 1
      }
      this.$http.post(this.$http.defaults.recruitAPI + 'api/' + tableName + '/queryByPage', para).then(response => {
        this.listLoading = false
        if (response.data.success === true) {
          this.list = response.data.result.records
        } else {
          console.log('获取数据失败:' + response.data.message)
          this.$message({
            message: '获取数据失败:' + response.data.message,
            type: 'error'
          })
        }
      }).catch(error => {
        console.log(error)
        this.$message({
          message: '网络获取失败:' + error,
          type: 'error'
        })
        this.listLoading = false
      })
      if (this.step === 'bus_candidate_registration') {
        let para2 = {
          pageNum: 1,
          pageSize: 1000,
          unitBatchId: this.unitBatchId,
          theType: 2
        }
        this.$http.post(this.$http.defaults.recruitAPI + 'api/' + tableName + '/queryByPage', para2).then(response => {
          this.listLoading = false
          if (response.data.success === true) {
            this.list_2 = response.data.result.records
          } else {
            console.log('获取数据失败:' + response.data.message)
            this.$message({
              message: '获取数据失败:' + response.data.message,
              type: 'error'
            })
          }
        }).catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
          this.listLoading = false
        })
      }
    },
    editFormSubmit () {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          this.editLoading = true
          let para = {
            id: this.editForm.id,
            unitName: this.editForm.unitName,
            theType: this.editForm.theType,
            department: this.editForm.department,
            post: this.editForm.post,
            realName: this.editForm.realName,
            idCardNo: this.editForm.idCardNo,
            sex: this.editForm.sex,
            nation: this.editForm.nation,
            maritalStatus: this.editForm.maritalStatus,
            phone: this.editForm.phone,
            school: this.editForm.school,
            schoolLocation: this.editForm.schoolLocation,
            place: this.editForm.place,
            major: this.editForm.major,
            majorClass1: this.editForm.majorClass1,
            majorClass2: this.editForm.majorClass2,
            education: this.editForm.education,
            degree: this.editForm.degree,
            recruitmentMethod: this.editForm.recruitmentMethod,
            inputer: this.editForm.inputer,
            inputerPhone: this.editForm.inputerPhone,
            inputDate: this.editForm.inputDate,
            originalUnit: this.editForm.originalUnit,
            unitBatchId: this.unitBatchId
          }
          this.$http.post(this.$http.defaults.recruitAPI + `api/recruitBusCandidateRegistration/save`, para).then(response => {
            console.log(response.data.success)
            if (response.data.success === true) {
              this.$message({
                message: '提交成功',
                type: 'success'
              })
              this.addFormVisible = false
              this.editLoading = false
              this.getList()
            } else {
              console.log('提交失败:' + response.data.message)
              this.$message({
                message: '提交失败:' + response.data.message,
                type: 'error'
              })
              this.editLoading = false
            }
          }).catch(error => {
            console.log(error)
            this.$message({
              message: '提交失败:' + error,
              type: 'error'
            })
            this.editLoading = false
          })
        }
      })
    },
    editFormSubmitB () {
      this.$refs.editFormb.validate((valid) => {
        if (valid) {
          this.editLoading = true
          let para = {
            id: this.editFormb.id,
            unitName: this.editFormb.unitName,
            theType: this.editFormb.theType,
            department: this.editFormb.department,
            post: this.editFormb.post,
            realName: this.editFormb.realName,
            idCardNo: this.editFormb.idCardNo,
            sex: this.editFormb.sex,
            nation: this.editFormb.nation,
            maritalStatus: this.editFormb.maritalStatus,
            phone: this.editFormb.phone,
            school: this.editFormb.school,
            schoolLocation: this.editFormb.schoolLocation,
            place: this.editFormb.place,
            major: this.editFormb.major,
            majorClass1: this.editFormb.majorClass1,
            majorClass2: this.editFormb.majorClass2,
            education: this.editFormb.education,
            degree: this.editFormb.degree,
            recruitmentMethod: this.editFormb.recruitmentMethod,
            inputer: this.editFormb.inputer,
            inputerPhone: this.editFormb.inputerPhone,
            inputDate: this.editFormb.inputDate,
            originalUnit: this.editFormb.originalUnit,
            unitBatchId: this.unitBatchId
          }
          this.$http.post(this.$http.defaults.recruitAPI + `api/recruitBusCandidateRegistration/save`, para).then(response => {
            console.log(response.data.success)
            if (response.data.success === true) {
              this.$message({
                message: '提交成功',
                type: 'success'
              })
              this.addFormVisible_2 = false
              this.editLoading = false
              this.getList()
            } else {
              console.log('提交失败:' + response.data.message)
              this.$message({
                message: '提交失败:' + response.data.message,
                type: 'error'
              })
              this.editLoading = false
            }
          }).catch(error => {
            console.log(error)
            this.$message({
              message: '提交失败:' + error,
              type: 'error'
            })
            this.editLoading = false
          })
        }
      })
    },
    showBack () {
      this.backFormVisible = true
      this.backForm.remark = ''
    },
    beforeUpload (file) {
      console.log('文件类型')
      console.log(file.name)
      const isFormat = file.name.indexOf('.docx') > 0 || file.name.indexOf('.doc') > 0 || file.name.indexOf('.pdf') > 0 || file.name.indexOf('.DOCX') > 0 || file.name.indexOf('.DOC') > 0 || file.name.indexOf('.PDF') > 0 || file.name.indexOf('.wps') > 0 || file.name.indexOf('.WPS') > 0
      const isLt500M = file.size / 1024 / 1024 < 60
      if (!isLt500M) {
        this.$message.error('单个附件不能超过60M!')
      } else {
        this.saveloading = true
      }
      if (!isFormat) {
        this.$message.error('附件格式必须为word、pdf、wps!')
      } else {
        this.saveloading = true
      }
      return isFormat && isLt500M
    },
    async handleUploadSucc1 (response, file, fileList) {
      this.uploadSuccCommon(response, file, fileList, this.step, 'files')
    },
    uploadSuccCommon (response) {
      if (response.success) {
        let para = {
          id: response.result[0].id,
          businessId: this.unitBatchId,
          businessTable: 'bus_unit_batch',
          businessStep: this.step
        }
        this.$http.post(this.$http.defaults.recruitAPI + `api/recruitGenFileInfo/save`, para).then(res => {
          this.saveloading = false
          if (res.data.success === true) {
            this.$message({
              message: '上传成功！',
              type: 'success'
            })
            this.getFileList()
          } else {
            console.log('上传失败:' + res.data.message)
            this.$message({
              message: '上传失败:' + res.data.message,
              type: 'error'
            })
          }
        })
          .catch(error => {
            this.saveloading = false
            console.log(error)
            this.$message({
              message: '上传失败:' + error,
              type: 'error'
            })
          })
      } else {
        this.saveloading = false
        this.$message({
          message: '上传失败:' + response.message,
          type: 'error'
        })
      }
    },
    beforeRemove (file) {
      this.$confirm('确定删除' + file.fileName + '.' + file.fileType + '？', '提示', {
        type: 'warning'
      }).then(() => {
        this.handleRemove(file.id)
      })
    },
    handleRemove (id) {
      const url = 'api/recruitGenFileInfo/remove?id=' + id
      this.$http.get(this.$http.defaults.recruitAPI + url).then(res => {
        console.log('删除成功:', res)
        if (res.data.success === true) {
          this.getFileList()
          this.$message({
            message: '删除成功！',
            type: 'success'
          })
        }
      })
    },
    uploadError (err) {
      this.saveloading = false
      console.log(err)
      this.$message({
        message: '上传失败:' + err,
        type: 'error'
      })
    },
    download (id) {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.recruitAPI + 'api/recruitGenFileInfo/download?id=' + id)
    },
    getFileList () {
      this.fileListLoading = true
      let para = {
        businessId: this.unitBatchId,
        businessStep: this.step,
        businessTable: 'bus_unit_batch'
      }
      let objName = 'files'
      this.$http.post(this.$http.defaults.recruitAPI + `api/recruitGenFileInfo/getFiles`, para).then(response => {
        this.fileListLoading = false
        if (response.data.success === true) {
          this[objName] = response.data.result
        } else {
          console.log('获取失败:' + response.data.message)
          this.$message({
            message: '获取失败:' + response.data.message,
            type: 'error'
          })
        }
      }).catch(error => {
        console.log(error)
        this.$message({
          message: '网络获取失败:' + error,
          type: 'error'
        })
        this.fileListLoading = false
      })
    },
    getNum (i) {
      return i < 10 ? '0' + i : i
    },
    setState (state) {
      if (this.step === 'bus_candidate_registration' || this.step === 'bus_settlement_registration') {
        if (this.files.length === 0 && this.list.length === 0 && state === 1) {
          this.$message({
            message: '操作失败:您未填写任何信息',
            type: 'error'
          })
          return false
        }
      } else {
        if (this.files.length === 0 && state === 1) {
          this.$message({
            message: '操作失败:您未填写任何信息',
            type: 'error'
          })
          return false
        }
      }
      this.$confirm('确认' + (state === 1 ? '提交' : '退回') + '吗?', '提示', {
        type: 'warning'
      }).then(() => {
        var date = new Date() // 获取时间
        var year = date.getFullYear() // 获取年
        var month = date.getMonth() + 1 // 获取月
        var strDate = date.getDate() // 获取日
        let myDate = year + '-' + this.getNum(month) + '-' + this.getNum(strDate)
        let para = {
          id: this.unitBatchId
        }
        console.log(this.step)
        switch (this.step) {
          case 'bus_post_docking':
            para.jobDockingState = state
            para.jobDockingNew = 1
            para.jobDockingSubmitTime = myDate
            if (state === 5) {
              para.jobDockingRemark = this.backForm.remark
            }
            break
          case 'bus_interviewer_filing':
            para.interviewerFilingState = state
            para.interviewerFilingNew = 1
            para.interviewerFilingSubmitTime = myDate
            if (state === 5) {
              para.interviewerFilingRemark = this.backForm.remark
            }
            break
          case 'bus_interview_results':
            para.interviewResultsState = state
            para.interviewResultsNew = 1
            para.interviewResultsSubmitTime = myDate
            if (state === 5) {
              para.interviewResultsRemark = this.backForm.remark
            }
            break
          case 'bus_candidate_registration':
            para.candidateRegistrationState = state
            para.candidateRegistrationNew = 1
            para.candidateRegistrationSubmitTime = myDate
            if (state === 5) {
              para.candidateRegistrationRemark = this.backForm.remark
            }
            break
          case 'bus_settlement_registration':
            para.settlementRegistrationState = state
            para.settlementRegistrationNew = 1
            para.settlementRegistrationSubmitTime = myDate
            if (state === 5) {
              para.settlementRegistrationRemark = this.backForm.remark
            }
            break
        }
        console.log(para)
        this.btnLoading = true
        this.$http.post(this.$http.defaults.recruitAPI + `api/recruitBusUnitBatch/save`, para).then(response => {
          this.btnLoading = false
          if (response.data.success === true) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            this.$emit('getDetails')
          } else {
            console.log('操作失败:' + response.data.message)
            this.$message({
              message: '操作失败:' + response.data.message,
              type: 'error'
            })
          }
        }).catch(error => {
          this.btnLoading = false
          console.log(error)
          this.$message({
            message: '操作失败:' + error,
            type: 'error'
          })
        })
      })
    }
  }
}
</script>
<style scoped>
  .mytable{
    border-top: 1px solid #74a6cc;
    border-left: 1px solid #74a6cc;
    margin:0 10px 10px;
    width: calc(100% - 20px);
  }
  .mytable th{
    padding: 10px;
    border-right: 1px solid #74a6cc;
    border-bottom: 1px solid #74a6cc;
    vertical-align: top;
    line-height: 150%;
    background: #FAFAFA;
    width:200px;
    text-align:right;
  }
  .mytable td{
    padding: 10px;
    border-right: 1px solid #74a6cc;
    border-bottom: 1px solid #74a6cc;
    vertical-align: top;
    line-height: 150%;
  }
</style>
<style>
#recruitTable .el-table{
  border:1px solid #95B8E7 !important;
}
#recruitTable .el-table td, #recruitTable .el-table th{
  border-right:1px solid #95B8E7 !important;
  border-bottom:1px solid #95B8E7 !important;
}
</style>
